import httpUtils from "./XmlHttpTool";

var boxItem = cc.Class({
    name: 'boxItem',
    properties: {
     iconString:cc.String
    }
});


cc.Class({
    extends: cc.Component,

    properties: {
        items: {
            default: [],
            type: boxItem
        },
        itemPrefab: cc.Prefab
    },

    // onLoad () {},

    start () {

    },

    init(){

        if(this.items.length>0){
            this.node.removeAllChildren();
        }

        var that=this
        httpUtils.NhttpPost("/marmot/game_box",{},function(res){
                
            console.log("游戏盒子动态",res);
            that.items=res
            for (var i = 0; i < that.items.length; ++i) {
            
                var item = cc.instantiate(that.itemPrefab);
                that.node.addChild(item);
                item.getComponent('boxPrefab').init(that.items[i]);
             
            }
       
           
        })
    },

    // update (dt) {},
});
